package com.clusterswisdom.horn.api.ioc.struct;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Element;

public class StructSource {

	private String table;
	
	private List<SourceField> fields;

	public StructSource(Element element) {
		this.table = element.attributeValue("table");
		this.fields = new ArrayList<SourceField>(10);
		
		Iterator<Element> elementIterator = element.elementIterator("field");
		while (elementIterator.hasNext()) {
			Element fieldElement = elementIterator.next();
			fields.add(new SourceField(fieldElement));
		}
	}
	
	public String getTable() {
		return table;
	}

	public void setTable(String table) {
		this.table = table;
	}

	public List<SourceField> getFields() {
		return fields;
	}

	public void setFields(List<SourceField> fields) {
		this.fields = fields;
	}
}